package com.ojoin.trade.supplyloan_core.web.controller;

import java.util.List;

import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ojoin.trade.common.utils.CommonUtils;
import com.ojoin.trade.common.utils.TimeUtils;
import com.ojoin.trade.common.web.controller.BaseController;
import com.ojoin.trade.common.web.controller.BaseControllerImpl;
import com.ojoin.trade.common.web.domain.Result;
import com.ojoin.trade.common.web.service.BaseService;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlSupplyloginCheck;
import com.ojoin.trade.supplyloan_core.web.service.TbSlSupplyloginCheckService;

@Controller
@RequestMapping("/supplylogincheck")
public class SlSupplyloginCheckController extends
		BaseControllerImpl<TbSlSupplyloginCheck> implements
		BaseController<TbSlSupplyloginCheck> {

	private org.slf4j.Logger log = LoggerFactory
			.getLogger(SlSupplyloginCheckController.class);

	@Autowired
	private TbSlSupplyloginCheckService service;

	@Override
	protected BaseService<TbSlSupplyloginCheck> getBaseService() {

		return service;
	}

	@ResponseBody
	@RequestMapping(value = "/querynotlogin", method = RequestMethod.GET)
	public Result querySupplyChainPlatformUserCanNotLogin(int joinid) {

		try {
			List<TbSlSupplyloginCheck> li = service
					.querySupplyChainPlatformUserCanNotLogin(joinid,
							TimeUtils.getCurDate());
			return new Result(Result.Status.OK, li);
		} catch (Exception e) { 
			log.error("", e);
			return new Result(Result.Status.ERROR, "");
		}
	} 
    
	@ResponseBody
	@RequestMapping(value = "/operate/queryById", method = {RequestMethod.GET,RequestMethod.POST})
	public Result queryById(String idOfPlatformUser,String time) { 
 
		try {
			log.info("idOfPlatformUser->"+idOfPlatformUser+"time->"+time); 
			TbSlSupplyloginCheck tbl = new TbSlSupplyloginCheck();
			if(!CommonUtils.isEmpty(idOfPlatformUser)){
				tbl.setIdOfPlatformUser(Integer.valueOf(idOfPlatformUser));
			}
		
			tbl.setCheckDate(time); 
			TbSlSupplyloginCheck tbsl = service.queryOne(tbl);
			return new Result(Result.Status.OK, tbsl);
		} catch (Exception e) {
			log.error("", e);
			return new Result(Result.Status.ERROR, "");
		}

	}
	
}
